<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<fmt:setBundle basename="messages" />
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><fmt:message key="PAGE_CABINET" /></title>
<link rel="stylesheet" type="text/css" href="css/mainStyle.css" />
</head>
<body onload="history.pushState(null, null, 'action?command=cabinet')">
	<jsp:include page="headerCabinet.jsp" />
	
	<div id="personalInfoForm">
		<div id="personalImage">
			<img
				src="${pageContext.servletContext.contextPath}/images/profile.jpg"
				width="65" align="left" hspace="15" />
		</div>
		<div id="personalInfo">
			${sessionScope.student.name}<br>
			<fmt:message key="LABEL_SCORE" />
			${sessionScope.student.totalScore}<br>
			<fmt:message key="LABEL_FACULTY" />
			${sessionScope.faculty.facultyName}
			<c:if
				test="${(sessionScope.faculty==null) && (sessionScope.facultyList==null)}"><jsp:forward
					page="/action?command=cabinet" /></c:if>
			<c:if test="${sessionScope.approved!=null}"><jsp:forward
					page="/action?command=cabinet" /></c:if>
			<c:if test="${ not empty sessionScope.faculty.facultyName}">
				<c:if test="${not empty sessionScope.student.approved}">
					<img
						src="${pageContext.servletContext.contextPath}/images/true.jpg"
						width="20" />
				</c:if>
				<c:if test="${empty sessionScope.student.approved}">
					<img
						src="${pageContext.servletContext.contextPath}/images/false.jpg"
						width="15" />
				</c:if>
			</c:if>
			<br>

		</div>
		<form action="action" method="post">
			<input type="hidden" name="command" value="logout" /> <input
				type="submit" value="<fmt:message key="BUTTON_LOGOUT" />"
				id="logoutButton">
		</form>
	</div>
	<c:if test="${not empty sessionScope.student.accepted}">
		<h1 align="center">
			<fmt:message key="LABEL_JOIN" />
		</h1>
	</c:if>
	<c:if
		test="${(not empty sessionScope.faculty.facultyId) && (empty sessionScope.student.accepted) && 
		(empty sessionScope.admissionState)}">
		<h1 align="center">
			<fmt:message key="LABEL_ENROLL" />
			${sessionScope.faculty.facultyName}
		</h1>
		<c:if test="${ empty sessionScope.student.approved}">
			<h1 align="center">
				<fmt:message key="LABEL_WAIT" />
			</h1>
		</c:if>
	</c:if>
	<c:if
		test="${(not empty sessionScope.admissionState) && (empty sessionScope.student.accepted)}">
		<h1 align="center">
			<fmt:message key="LABEL_TRYNEXT" />
		</h1>
	</c:if>

	<c:if
		test="${(empty sessionScope.faculty) && (empty sessionScope.admissionState)}">
		<div id="facultyForm">
			<form action="action" method="post">
				<input type="hidden" name="command" value="enroll" /> <select
					name="facultyId" size="1" id="selectMenu">
					<c:forEach var="faculty" items="${sessionScope.facultyList}">
						<option value="${faculty.facultyId}">${faculty.facultyName}</option>
					</c:forEach>
				</select> <input type="submit" value="<fmt:message key="BUTTON_ENROLL"/>"
					id="button"><br> <input type="text" name="mark1"
					placeholder="<fmt:message key="INPUT_MARK1"/>"
					pattern="^0?[0-9]?[0-9]$|^(100)$"
					title="Only integer values from 0 to 100" required /><br> <input
					type="text" name="mark2"
					placeholder="<fmt:message key="INPUT_MARK2"/>"
					pattern="^0?[0-9]?[0-9]$|^(100)$"
					title="Only integer values from 0 to 100" required /><br> <input
					type="text" name="mark3"
					placeholder="<fmt:message key="INPUT_MARK3"/>"
					pattern="^0?[0-9]?[0-9]$|^(100)$"
					title="Only integer values from 0 to 100" required /><br> <input
					type="text" name="certificate"
					placeholder="<fmt:message key="INPUT_CERT"/>"
					pattern="^0?[0-9]?[0-9]$|^(100)$"
					title="Only integer values from 0 to 100" required /><br>
			</form>
		</div>
	</c:if>
	<jsp:include page="footer.jsp" />
</body>
</html>